#ifndef BASEPLUGIN_H
#define BASEPLUGIN_H

#include <QString>
#include <QObject>
#include <QVector>
#include <functional>


#include "common_global.h"
#include "global/Event.h"

enum PluginType{
    System,
    User,
    TopWidget,
    LeftWidget,
    ButtomWidget,
    RightWidget,
    CenterWidget,
    QuickWidget
};

class BasePluginPrivate;

class COMMONSHARED_EXPORT BasePlugin : public QObject
{
    Q_OBJECT
public:
    BasePlugin(QString name, QString description = "", QObject* parent = nullptr);
    virtual ~BasePlugin();
    QString GetName();
    QString GetDescription();
    QVector<PluginType>& GetType();

    bool AddType(PluginType type);
    bool HasType(PluginType type);

    //所有插件Load前调用
    virtual void PreLoad(){}

    //插件加载
    virtual void OnLoad(int argc, char **argv){}

    //所有插件加载完毕
    virtual void AfterLoad(){}

    virtual void* HandleEvent(Event event, void* pData, BasePlugin* pSender);

    virtual QWidget* GetWidget(){return nullptr;}
signals:

public slots:

private:
    BasePluginPrivate* _p;
};

QT_BEGIN_NAMESPACE

#define BasePlugin_iid "NationalFramework.BasePlugin_iid"

Q_DECLARE_INTERFACE(BasePlugin, BasePlugin_iid)
QT_END_NAMESPACE

#endif // BASEPLUGIN_H
